﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using System.IO;

namespace The_Square_Saga.Utils
{
    public enum Directions
    {
        RIGHT, LEFT, UP, DOWN, NONE,
    }
    public enum Axis
    {
        X,Y
    }
    class Util
    {
        public static bool isNull(object T)
        {
            if (T != null)
                return false;
            
            return true;
        }

        public static Vector2 getDirectionAngle(Vector2 u, Vector2 v)
        {
            Vector2 r = v - u;
            float mU = (float)Math.Sqrt((u.X * u.X) + (u.Y * u.Y));
            float mV = (float)Math.Sqrt((v.X * v.X) + (v.Y * v.Y));
            if (mU == 0)
                mU = 1;
            if (mV == 0)
                mV = 1;
            float b = mU * mV;
            if (r.X >= 0.5f)
            {
                r.X = (float)Math.Ceiling(r.X / b);
            }
            else
            {
                r.X = (float)Math.Floor(r.X / b);
            }
            if (r.Y >= 0.5f)
            {
                r.Y = (float)Math.Ceiling(r.Y / b);
            }
            else
            {
                r.Y = (float)Math.Floor(r.Y / b);
            }
            return new Vector2(r.X, r.Y);
        }

        /// <summary>
        /// Open a stream
        /// </summary>
        /// <param name="fileName">A fileName</param>
        /// <returns>A file name</returns>
        public static Stream getStreamFile(string fileName)
        {
            Stream stream = TitleContainer.OpenStream(fileName);
            
            return stream;
        }
    }
}
